package com.example.ordersystem;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.ordersystem.pojo.Food;
import com.example.ordersystem.utils.FoodAdapter;
import com.example.ordersystem.utils.ListDataSave;

import java.util.ArrayList;
import java.util.List;

/*
 * 菜单页面
 */
public class MenuActivity extends AppCompatActivity implements View.OnClickListener {
    private List<Food> foodList = new ArrayList<>();

    private ImageView menu_to_home;
    private String storeName;
    Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        storeName = getIntent().getStringExtra("storeName");
        foodList = ListDataSave.getMenuList(this, storeName);

        FoodAdapter foodadapter = new FoodAdapter(this, R.layout.food, this.foodList);
        ListView listView = findViewById(R.id.menu_list_view);
        listView.setAdapter(foodadapter);

        initView();
    }

    private void initView() {
        menu_to_home = findViewById(R.id.menu_to_home);
        menu_to_home.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.menu_to_home:
                intent = new Intent(MenuActivity.this, MainActivity.class);
                startActivity(intent);
                break;
        }
    }

}
